home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / c / MemPools.lha / MemPools.readme < prev    next >
Text File  |  1998-03-12  |  6KB  |  154 lines

  1. short: fast malloc() replacement, v1.3
  2. type: dev/c
  3. author: mandree@dosis.uni-dortmund.de, jochen.wiedmann@uni-tuebingen.de
  4. uploader: mandree@dosis.uni-dortmund.de
  5. replaces: dev/c/MemPools*.lha
  6.  
  7. CHANGES by Matthias Andree
  8. ==========================
  9.  
  10. 1.2 -> 1.3 (1998-03-12)
  11.  
  12.     Since  DICE  is  to  be  considered  entirely  out-of-date,  I  removed  all
  13.     references  to  DICE, and reworked things a bit. I was trying to link a tool
  14.     with SAS/C 6.58, which - according to MUNGWALL SNOOP output - stuck with  4k
  15.     blocks.  Investigating this further, I found that mempools.lib did not offer
  16.     regargs entry points, thus, my tool stuck with SAS/C stdlib  pooling  (which
  17.     uses  4k  blocks  currently).  I  fixed  this  flaw  and  some  little other
  18.     peculiarities.
  19.  
  20.     NOTE: the debug feature Jochen Wiedmann stated below is indeed  included  in
  21.     the  sources,  but  cannot currently be used to automatically build an SAS/C
  22.     mempoolsd.lib.
  23.  
  24.     NOTE: The make files are a horrible mess.
  25.  
  26.  
  27.  
  28. MemPools - malloc() replacement using standard Exec memory pools
  29. ================================================================
  30.  
  31. Many people don't like using malloc() and similar functions because  they  think
  32. it's  too  slow  and  gives too much overhead. Well, as far as I can say they're
  33. alright, at least for users of SAS/C: The Exec pool  functions  seem  to  be  at
  34. least  5 times faster and it can even be faster than the malloc() of GNU C! (See
  35. "Timings" below.)
  36.  
  37. Other people like malloc(): It's portable and rather easy to use. I  am  one  of
  38. these, however I don't want to loose the speed of pool functions.
  39.  
  40. The mempools package is a link library with the  functions  malloc(),  calloc(),
  41. realloc(),  strdup() and free(). It replaces the compilers own functions by just
  42. linking against this library. No additional work  is  required  as  the  library
  43. takes use of the compilers auto- initialization facility.
  44.  
  45. Ths autoinitialization restricts use of the mempools library to users  of  SAS/C
  46. and gcc.
  47.  
  48. Note, that pools are available not  only  for  users  of  OS  3.x!  The  current
  49. amiga.lib  offers  replacements  which  call  exec.library, if the OS is 3.x and
  50. emulate pools otherwise. The MemPools library uses this replacements.
  51.  
  52.  
  53. A debugging possibility very similar to Mungwall is integrated into the library,
  54. which  is  enabled  by  compiling  with  -DDEBUG. The makefiles provide a target
  55. "mempoolsd.lib" which does just that.
  56.  
  57.  
  58.  
  59. 1.) Disclaimer: Copyrights, (No) Warranty
  60. -----------------------------------------
  61.  
  62. This program is Copyright (C) 1994  Jochen Wiedmann
  63.                     Am Eisteich 9
  64.                     72555 Metzingen
  65.                     Germany
  66.  
  67.                     Phone: (0049) +7123 / 14881
  68.                     Mail: jochen.wiedmann@uni-tuebingen.de
  69.  
  70. All changes are Copyright (C) 1998  Matthias Andree
  71.                     Stormstr. 14
  72.                     58099 Hagen
  73.                     Germany
  74.  
  75.                     Phone: +49-(0)23 31-96 30 72
  76.                     Mail: mandree@dosis.uni-dortmund.de
  77.  
  78.  
  79. Permission is granted to make and distribute either verbatim and modified copies
  80. of this documentation and the library MemPools provided the copyright notice and
  81. this permission notice are preserved on all copies and the "GNU  General  Public
  82. License" (in the file COPYING) is distributed as well.
  83.  
  84. The authors give ABSOLUTELY NO warranty that  the  software  described  in  this
  85. documentation  and  the results produced by them are correct. The authors cannot
  86. be held responsible for ANY damage resulting from the use of this software.
  87.  
  88.  
  89.  
  90. 2.) Installation
  91. ----------------
  92.  
  93. There are two libraries  included  in  the  distribution,  it  depends  on  your
  94. compiler  which  one  you  need:  mempools.lib  is for SAS/C, its destination is
  95. sc:lib. libmempools.a is the GNU-c version which should go to GNU:lib.
  96.  
  97. If you want to recreate them, just type smake (SAS/C) or make (GNU-c).
  98.  
  99.  
  100.  
  101. 3.) Usage
  102. ---------
  103.  
  104. All you have to do is to link against the appropriate mempools library.
  105.  
  106. a) SAS/C
  107.  
  108.     Add the option LIB mempools.lib to your compiler  statement.  By  using  the
  109.     "scopts" program you can get this automatically, too.
  110.  
  111. b) gcc
  112.  
  113.     Add the option -lmempools to your compiler statement. I don't  know  if  gcc
  114.     can handle this automatically. Probably someone can enlighten me?
  115.  
  116. However, you might be interested in controlling the pools attributes.  This  can
  117. be  done  by  creating global variables __MemPoolPuddleSize, __MemPoolThreshSize
  118. and __MemPoolFlags  which  correspond  to  the  arguments  of  the  CreatePool()
  119. function.  For example, if you want to modify the puddle size (this can increase
  120. speed, see "Timings" below), just add  the  following  line  somewhere  to  your
  121. program:
  122.  
  123.     ULONG __MemPoolPuddleSize = 16384;  /*  Default: 4096       */
  124.  
  125. Or if you want malloc() to obtain chip memory, just write
  126.  
  127.     #include <exec/memory.h>
  128.     ULONG __MemPoolFlags = MEMF_CHIP;   /*  Default: MEMF_ANY   */
  129.  
  130.  
  131.  
  132.  
  133. 4.) Timings
  134. -----------
  135.  
  136. I wrote a little timing program. (I don't claim that it is very  good,  probably
  137. someone can write a better one.) I was rather surprised about the results:
  138.  
  139.     Compiler    Time (Mins:Secs)    Notes
  140.  
  141.     SAS/C       1:17,66             SAS/C uses an own pool system.
  142.                     Thus, the exit() function is
  143.                     rather fast. malloc(), however,
  144.                     seems to be slow.
  145.  
  146.     gcc         0:12,84 (ixemul)    gcc uses a pool system which is
  147.         0:14,34 (libnix)    rather close to Exec pools. This
  148.                     gives good results.
  149.  
  150.     MemPools    0:15,10 (4096)      By increasing the puddle size
  151.         0:12,14 (8192)      (see "Usage") you get better
  152.         0:10,80 (16384)     results! It seems worth to try a
  153.                     little bit.
  154.